/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public ListNode deleteNode(ListNode head, int val) {
        ListNode newHead = new ListNode(-1);
        newHead.next = head;
        ListNode slow = newHead;
        ListNode fast = head;
        while(slow != null && slow.next != null){
            if(fast.val == val){
                slow.next = slow.next.next;
            }
            fast = fast.next;
            slow = slow.next;
        }
        return newHead.next;
    }
}

